<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生练习数据管理平台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            background-image: url('../../static/img/jpg/background.jpg');
            background-attachment:fixed;
            background-clip: border-box;
            background-size: cover;
        }

        .container {
            display: grid;
            grid-template-areas:
                "header header header"
                ". chart-container weatherforecast"
                ". chart-container ."
                ". chart-container ."
                "bottom bottom bottom";
            grid-template-columns: 1fr 4fr 2fr;
            gap: 10px;
            height: 100vh;
        }

        .dropdown {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background-image: url('../../static/img/jpg/background.jpg');
            position: relative;
        }

        .logo {
            font-size: 16px;
            font-weight: bold;
            text-align:left;
            display: none;
            position: absolute;
            top: 100%;
            left: -50%;
            background-color: rgba(245, 245, 245, 0.9);
            color: black;
            padding: 10px;
            border-radius: 10px;
            box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
            z-index: 1;
        }

        .dropdown:hover .logo {
            display: block;
        }

        .header {
            grid-area: header;
            background-color: rgba(245, 245, 245, 0.6);
            color: black;
            display: flex;
            justify-content: space-around;
            align-items: center;
            font-size: 18px;
            border-radius: 10px;
            height: 120px;
            position: sticky;
            top: 0;
            transition: transform 0.3s ease-in-out;
            z-index: 100;
        }

        .header.hidden {
            transform: translateY(-100%);
        }

        .main {
            grid-area: chart-container;
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 20px;
        }

        .main .chart-container {
            background-color: rgba(255, 255, 255, 0.6);
            border: 1px solid #ccc;
            border-radius: 10px;
            padding: 15px;
            display: flex;
            justify-content: space-around;
            align-items: center;
            flex-direction: column;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .main .chart-container canvas {
            width:100px;
            height: 100px;
        }

        .main .chart-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 10px;
        }

        .weather_forecast {
            grid-area: weatherforecast;
            background-color: rgba(245, 245, 245, 0.6);
            border: 1px solid #ccc;
            border-radius: 10px;
            padding: 15px;
            display: flex;
            align-items: flex-start;
            flex-direction: column;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            width: 300px;
            height: 400px;
        }

        /*以下代码为菜单UI From Uiverse.io by Cornerstone-04 */
        .box {
            width: 140px;
            height: auto;
            float: left;
            transition: .5s linear;
            position: relative;
            display: block;
            overflow: hidden;
            padding: 15px;
            text-align: center;
            margin: 0 5px;
            background: transparent;
            text-transform: uppercase;
            font-weight: 900;
        }

        .box:before {
            position: absolute;
            content: '';
            left: 0;
            bottom: 0;
            height: 4px;
            width: 100%;
            border-bottom: 4px solid transparent;
            border-left: 4px solid transparent;
            box-sizing: border-box;
            transform: translateX(100%);
        }

        .box:after {
            position: absolute;
            content: '';
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            border-top: 4px solid transparent;
            border-right: 4px solid transparent;
            box-sizing: border-box;
            transform: translateX(-100%);
        }

        .box:hover {
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        .box:hover:before {
            border-color: #262626;
            height: 100%;
            transform: translateX(0);
            transition: .3s transform linear, .3s height linear .3s;
        }

        .box:hover:after {
            border-color: #262626;
            height: 100%;
            transform: translateX(0);
            transition: .3s transform linear, .3s height linear .5s;
        }

        button {
            color: black;
            text-decoration: none;
            cursor: pointer;
            outline: none;
            border: none;
            background: transparent;
        }

        /*以下为搜索框UI From Uiverse.io by garerim */
        .container-input {
            position: relative;
        }

        .input {
            width: 200px;
            padding: 10px 0px 10px 40px;
            border-radius: 9999px;
            border: solid 1px #333;
            transition: all .2s ease-in-out;
            outline: none;
            opacity: 0.8;
        }

        .container-input svg {
            position: absolute;
            top: 50%;
            left: 10px;
            transform: translate(0, -50%);
        }

        .input:focus {
            opacity: 1;
            width: 250px;
        }

        .dropdown:hover .logo {
            display: inline-block;
            position:relative;
            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
        }

        .bottom {
            grid-area: bottom;
            background-color: rgba(245, 245, 245, 0.9);
            color: black;
            display: flex;
            justify-content: space-around;
            align-items: center;
            font-size: 18px;
            border-radius: 10px;
            height: 120px;
            position: relative;
        }

    </style>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div class="container">
    <div class="header">
        <div id="head_png">
            <img src="../../static/img/icon/头标.svg" alt="None">
        </div>
        <button class="menu" id="home">
                    <span class="box">
                        <img src="../../static/img/icon/首页.svg" alt="None"><br>
                        首页
                    </span>
        </button>
        <button class="menu" id="blog">
                    <span class="box">
                        <img src="../../static/img/icon/博客.svg" alt="None"><br>
                         博客
                    </span>
        </button>
        <button class="menu" id="tools_box">
                    <span class="box">
                        <img src="../../static/img/icon/工具箱.svg" alt="None"><br>
                        工具箱
                    </span>
        </button>
        <button class="menu" id="contest">
                    <span class="box">
                        <img src="../../static/img/icon/比赛.svg" alt="None"><br>
                        比赛
                    </span>
        </button>
        <button class="menu" id="ranking">
                    <span class="box">
                        <img src="../../static/img/icon/排名.svg" alt="None"><br>
                        排名
                    </span>
        </button>
        <!-- From Uiverse.io by garerim -->
        <div class="container-input">
            <input type="text" placeholder="Search" name="text" class="input">
            <svg fill="#000000" width="20px" height="20px" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg">
                <path d="M790.588 1468.235c-373.722 0-677.647-303.924-677.647-677.647 0-373.722 303.925-677.647 677.647-677.647 373.723 0 677.647 303.925 677.647 677.647 0 373.723-303.924 677.647-677.647 677.647Zm596.781-160.715c120.396-138.692 193.807-319.285 193.807-516.932C1581.176 354.748 1226.428 0 790.588 0S0 354.748 0 790.588s354.748 790.588 790.588 790.588c197.647 0 378.24-73.411 516.932-193.807l516.028 516.142 79.963-79.963-516.142-516.028Z" fill-rule="evenodd"></path>
            </svg>
        </div>
        <button class="dropdown" id="head_svg">
            <div class="logo">
                <p>姓名：张三</p>
                <p>职业：学生练习分析员</p>
                <p>邮箱：zhangsan@example.com</p>
            </div>
        </button>
    </div>
    <div class="main">
        <div class="chart-container">
            <div class="chart-title">Codeforces分析</div>
            <canvas id="rating1"></canvas>
            <canvas id="problems1"></canvas>
        </div>
        <div class="chart-container">
            <div class="chart-title">Atcoder分析</div>
            <canvas id="rating2"></canvas>
            <canvas id="problems2"></canvas>
        </div>
        <div class="chart-container">
            <div class="chart-title">Luogu分析</div>
            <canvas id="rating3"></canvas>
            <canvas id="problems3"></canvas>
        </div>
        <div class="chart-container">
            <div class="chart-title">Vjudge分析</div>
            <canvas id="rating4"></canvas>
            <canvas id="problems4"></canvas>
        </div>
        <div class="chart-container">
            <div class="chart-title">NCSTOJ分析</div>
            <canvas id="rating5"></canvas>
            <canvas id="problems5"></canvas>
        </div>
        <div class="chart-container">
            <div class="chart-title">Nowcoder分析</div>
            <canvas id="rating6"></canvas>
            <canvas id="problems6"></canvas>
        </div>
    </div>
    <div class="weather_forecast">
        <img src="..\..\attachments\img\icon\定位.svg" alt="None">北京
    </div>
    <div class="bottom">
        我们的网站
    </div>
</div>
<script>

    let lastScrollTop = 0;
    const header = document.querySelector('.header');

    window.addEventListener('scroll', function() {
        let scrollTop = window.pageYOffset || document.documentElement.scrollTop;

        if (scrollTop > lastScrollTop) {

            header.classList.add('hidden');
        } else {

            header.classList.remove('hidden');
        }

        lastScrollTop = scrollTop;
    });

    document.getElementById("blog").onclick = function() {
        window.location.href = "file:///C:/Users/203_444444/Desktop/flaskProject/templates/user/blog.html";
    };

    document.getElementById("tools_box").onclick = function() {
        window.location.href = "file:///C:/Users/203_444444/Desktop/flaskProject/templates/user/tools_box.html";
    };

    document.getElementById("contest").onclick = function() {
        window.location.href = "file:///C:/Users/203_444444/Desktop/flaskProject/templates/user/contest.html";
    };

    document.getElementById("ranking").onclick = function() {
        window.location.href = "file:///C:/Users/203_444444/Desktop/flaskProject/templates/user/ranking.html";
    };

    const generateComparisonChart = (ctx, selfValue, maxValue, label) => {
        new Chart(ctx, {
            type: 'doughnut',
            data: {
                labels: [label, '剩余'],
                datasets: [{
                    data: [selfValue, maxValue - selfValue],
                    backgroundColor: ['rgba(255, 99, 132, 0.6)', 'rgba(75, 192, 192, 0.6)'],
                    borderColor: ['rgba(255, 99, 132, 1)', 'rgba(75, 192, 192, 1)'],
                    borderWidth: 1
                }]
            },
            options: {
                responsive: true,
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function (context) {
                                const label = context.label || '';
                                const value = context.raw;
                                return `${label}: ${value}`;
                            }
                        }
                    }
                }
            }
        });
    };

    const maxValues = {
        rating: 2000,
        problems: 500
    };

    generateComparisonChart(
        document.getElementById('rating1').getContext('2d'),
        1200,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems1').getContext('2d'),
        300,
        maxValues.problems,
        '过题数'
    );

    generateComparisonChart(
        document.getElementById('rating2').getContext('2d'),
        1100,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems2').getContext('2d'),
        250,
        maxValues.problems,
        '过题数'
    );

    generateComparisonChart(
        document.getElementById('rating3').getContext('2d'),
        1000,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems3').getContext('2d'),
        200,
        maxValues.problems,
        '过题数'
    );

    generateComparisonChart(
        document.getElementById('rating4').getContext('2d'),
        900,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems4').getContext('2d'),
        150,
        maxValues.problems,
        '过题数'
    );

    generateComparisonChart(
        document.getElementById('rating5').getContext('2d'),
        800,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems5').getContext('2d'),
        100,
        maxValues.problems,
        '过题数'
    );

    generateComparisonChart(
        document.getElementById('rating6').getContext('2d'),
        700,
        maxValues.rating,
        'Rating'
    );
    generateComparisonChart(
        document.getElementById('problems6').getContext('2d'),
        50,
        maxValues.problems,
        '过题数'
    );
</script>
</body>
</html>
